#include <iostream>
#include <fstream>

using std::cout;
using std::endl;
using std::ifstream;
using std::ios;

int main(void)
{
    // 打开
    ifstream ifs("1.txt");

    // 偏移到末尾
    ifs.seekg(0, ios::end);
    size_t pos = ifs.tellg();

    // 偏移到开头
    ifs.seekg(0, ios::beg);

    // 读取并输出
    char* buffer = new char[pos] ();
    ifs.read(buffer, pos - 1);
    cout << buffer << endl;

    // 善后    
    ifs.close();
    delete [] buffer;
}